#include "UdpServer.hpp"
#include "Comm.hpp"
#include <memory>

void Usage(std::string proc)
{
    std::cout << "Usage: \n\t" << proc  << " local_port" << std::endl;
}


// ./udp_serve 0.0.0.0 port
int main(int argc,char** argv)
{
    if(argc != 2)
    {
        Usage(argv[0]);
        return usage_err;
    }

    //std::string ip = argv[1];
    uint16_t port = std::stoi(argv[1]);
    //c++14中一个用于动态分配对象的智能指针工厂函数，简化动态内存管理并减少内存泄漏的风险
    std::unique_ptr<Udpserve> usvr = std::make_unique<Udpserve> (port);
    //std::unique_ptr<Udpserve> usvr(new Udpserve("0.0.0.0"))
    usvr->init();
    usvr->start();
    
    return 0;
}